﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Configuration;
using System.Xml;
using System.Xml.Linq;

namespace GONES.Tools.Common
{
    /// <summary>
    /// 系统名词定义类
    /// </summary>
    public class CNoun
    {
        private static CNoun _nounSingleton;

        private string _entityCode="单位注册号";
        private string _entityName = "企业名称/姓名";
        private string _proCode="条形码";
        private string _proName="商品名称";
        private string _sEntityCode="供应商注册号";
        private string _sEntityName="供应商名称";
        private string _aEntityCode="经销商注册号";
        private string _aEntityName="经销商名称";
        private string _govCode="组织机构代码";
        private string _govName="单位名称";
        private string _pEntityCode="生产企业注册号";
        private string _pEntityName="生产企业名称";
        private string _ipcCertName="批检报告";
        private string _cxtName="诚信通";
        private string _authType = "QS号";
        private string _patrolGEntity = "巡查人员单位名称";
        private string _patrolEntity = "被巡查单位名称";

        /// <summary>
        /// 巡查人员单位名称
        /// </summary>
        public string PatrolGEntity
        {
            get { return _patrolGEntity; }
        }

       /// <summary>
        /// 被巡查单位名称
       /// </summary>
        public string PatrolEntity
        {
            get { return _patrolEntity; }
        }

        /// <summary>
        /// 单位注册号
        /// </summary>
        public string EntityCode
        {
            get { return _entityCode; }
        }

        /// <summary>
        /// 单位名称
        /// </summary>
        public string EntityName
        {
            get { return _entityName; }
        }

        /// <summary>
        /// 条形码
        /// </summary>
        public string ProCode
        {
            get { return _proCode; }
        }

        /// <summary>
        /// 商品名称
        /// </summary>
        public string ProName
        {
            get { return _proName; }
        }

        /// <summary>
        /// 供应商注册号
        /// </summary>
        public string SEntityCode
        {
            get { return _sEntityCode; }
        }

        /// <summary>
        /// 供应商名称
        /// </summary>
        public string SEntityName
        {
            get { return _sEntityName; }
        }

        /// <summary>
        /// 经销商注册号
        /// </summary>
        public string AEntityCode
        {
            get { return _aEntityCode; }
        }

        /// <summary>
        /// 经销商名称
        /// </summary>
        public string AEntityName
        {
            get { return _aEntityName; }
        }

        /// <summary>
        /// 监管部门组织机构代码
        /// </summary>
        public string GovCode
        {
            get { return _govCode; }
        }

        /// <summary>
        /// 监管部门名称
        /// </summary>
        public string GovName
        {
            get { return _govName; }
        }

        /// <summary>
        /// 生产企业注册号
        /// </summary>
        public string PEntityCode
        {
            get { return _pEntityCode; }
        }

        /// <summary>
        /// 生产企业名称
        /// </summary>
        public string PEntityName
        {
            get { return _pEntityName; }
        }

        /// <summary>
        /// 批检报告
        /// </summary>
        public string IpcCertName
        {
            get { return _ipcCertName; }
        }

        /// <summary>
        /// 终端名称
        /// </summary>
        public string CxtName
        {
            get { return _cxtName; }
        }

        /// <summary>
        /// 认证类型
        /// </summary>
        public string AuthType
        {
            get { return _authType; }
        }

        private CNoun()
        {
            XDocument xml = XDocument.Load(HttpContext.Current.Server.MapPath("~/Configs/CNoun.xml"));
            _entityCode =
                xml.Root.Elements("node").Where(n => n.Attribute("name").Value == "_entityCode").First().Attribute(
                    "value").Value;
            _entityName =
                xml.Root.Elements("node").Where(n => n.Attribute("name").Value == "_entityName").First().Attribute(
                    "value").Value;
            _proCode =
                xml.Root.Elements("node").Where(n => n.Attribute("name").Value == "_proCode").First().Attribute(
                    "value").Value;
            _proName =
                xml.Root.Elements("node").Where(n => n.Attribute("name").Value == "_proName").First().Attribute(
                    "value").Value;
            _sEntityCode =
                xml.Root.Elements("node").Where(n => n.Attribute("name").Value == "_sEntityCode").First().Attribute(
                    "value").Value;
            _sEntityName =
                xml.Root.Elements("node").Where(n => n.Attribute("name").Value == "_sEntityName").First().Attribute(
                    "value").Value;
            _aEntityCode =
                xml.Root.Elements("node").Where(n => n.Attribute("name").Value == "_aEntityCode").First().Attribute(
                    "value").Value;
            _aEntityName =
                xml.Root.Elements("node").Where(n => n.Attribute("name").Value == "_aEntityName").First().Attribute(
                    "value").Value;
            _govCode =
                 xml.Root.Elements("node").Where(n => n.Attribute("name").Value == "_govCode").First().Attribute(
                     "value").Value;
            _govName =
                xml.Root.Elements("node").Where(n => n.Attribute("name").Value == "_govName").First().Attribute(
                    "value").Value;
            _pEntityCode =
                xml.Root.Elements("node").Where(n => n.Attribute("name").Value == "_pEntityCode").First().Attribute(
                    "value").Value;
            _pEntityName =
                xml.Root.Elements("node").Where(n => n.Attribute("name").Value == "_pEntityName").First().Attribute(
                    "value").Value;
            _ipcCertName =
                xml.Root.Elements("node").Where(n => n.Attribute("name").Value == "_ipcCertName").First().Attribute(
                    "value").Value;
            _cxtName =
                xml.Root.Elements("node").Where(n => n.Attribute("name").Value == "_cxtName").First().Attribute(
                    "value").Value;
            _authType =
                xml.Root.Elements("node").Where(n => n.Attribute("name").Value == "_authType").First().Attribute(
                    "value").Value;
            _patrolGEntity =
                xml.Root.Elements("node").Where(n => n.Attribute("name").Value == "_patrolGEntity").First().Attribute(
                    "value").Value;
            _patrolEntity =
                xml.Root.Elements("node").Where(n => n.Attribute("name").Value == "_patrolEntity").First().Attribute(
                    "value").Value;
        }


        public static CNoun Instance
        {
            get { return _nounSingleton ?? (_nounSingleton = new CNoun()); }
        }
    }
}